package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.IndicatorDetail;
import com.ruoyi.business.service.IIndicatorDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 指标明细Controller
 * 
 * @author ruoyi
 * @date 2024-12-01
 */
@RestController
@RequestMapping("/business/indexDetail")
public class IndicatorDetailController extends BaseController
{
    @Autowired
    private IIndicatorDetailService indicatorDetailService;

    /**
     * 查询指标明细列表
     */
    @PreAuthorize("@ss.hasPermi('business:indexDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(IndicatorDetail indicatorDetail)
    {
        startPage();
        List<IndicatorDetail> list = indicatorDetailService.selectIndicatorDetailList(indicatorDetail);
        return getDataTable(list);
    }

    /**
     * 导出指标明细列表
     */
    @PreAuthorize("@ss.hasPermi('business:indexDetail:export')")
    @Log(title = "指标明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IndicatorDetail indicatorDetail)
    {
        List<IndicatorDetail> list = indicatorDetailService.selectIndicatorDetailList(indicatorDetail);
        ExcelUtil<IndicatorDetail> util = new ExcelUtil<IndicatorDetail>(IndicatorDetail.class);
        util.exportExcel(response, list, "指标明细数据");
    }

    /**
     * 获取指标明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:indexDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(indicatorDetailService.selectIndicatorDetailById(id));
    }

    /**
     * 新增指标明细
     */
    @PreAuthorize("@ss.hasPermi('business:indexDetail:add')")
    @Log(title = "指标明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IndicatorDetail indicatorDetail)
    {
        return toAjax(indicatorDetailService.insertIndicatorDetail(indicatorDetail));
    }

    /**
     * 修改指标明细
     */
    @PreAuthorize("@ss.hasPermi('business:indexDetail:edit')")
    @Log(title = "指标明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IndicatorDetail indicatorDetail)
    {
        return toAjax(indicatorDetailService.updateIndicatorDetail(indicatorDetail));
    }

    /**
     * 删除指标明细
     */
    @PreAuthorize("@ss.hasPermi('business:indexDetail:remove')")
    @Log(title = "指标明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(indicatorDetailService.deleteIndicatorDetailByIds(ids));
    }
}
